<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    div {
      padding: 15px;
      border: 1px solid black;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      display: flex;
      flex-direction: column;
    }

    input,
    button {
      margin: 10px;
    }
  </style>
</head>

<body>
  <div>
    <input type="text" placeholder="请输入账号">
    <input type="password" placeholder="请输入密码">
    <button>登陆</button>
    <button>注册</button>
  </div>
</body>
<script>
  var input = document.getElementsByTagName('input')
  var button = document.getElementsByTagName('button')
  button[0].onclick = function () {
    var username = input[0].value
    var password = input[1].value
    console.log(username, password)
  }

  
</script>

</html>